package com.my.main.service.userAndRight.serviceImpl;

import com.my.main.base.mapper.BaseMapper;
import com.my.main.base.service.Impl.BaseServiceImpl;
import com.my.main.entity.userAndRight.SysRightsRole;
import com.my.main.mapper.userAndRight.SysRightsRoleMapper;
import com.my.main.mapper.userAndRight.SysRightsRoleResourceMapper;
import com.my.main.mapper.userAndRight.SysRightsRoleUserRelationMapper;
import com.my.main.service.userAndRight.SysRightsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
@Transactional
public class SysRightsRoleServiceImpl extends BaseServiceImpl<SysRightsRole> implements SysRightsRoleService {

    @Autowired
    private SysRightsRoleMapper sysRightsRoleMapper;
    @Autowired
    private SysRightsRoleResourceMapper sysRightsRoleResourceMapper;
    @Autowired
    private SysRightsRoleUserRelationMapper sysRightsRoleUserRelationMapper;
    @Resource(name= "sysRightsRoleMapper")
    public void setBaseMapper(BaseMapper<SysRightsRole> mapper) { super.setBaseMapper(mapper); }


    @Override
    public void isDeleteRole(SysRightsRole role) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("roleId", role.getRoleId());

        sysRightsRoleResourceMapper.isDeleteByObject(map);
        sysRightsRoleUserRelationMapper.isDeleteByObject(map);
        sysRightsRoleMapper.isDeleteByUuid(role.getRoleId());
    }

}
